
import java.awt.Color;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import javax.print.attribute.standard.JobImpressions;
import javax.swing.JOptionPane;
import javax.swing.border.Border;
import javax.swing.plaf.basic.DefaultMenuLayout;




/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author ADM
 */
public class StatisticalBills extends javax.swing.JPanel {
    public static String BId,CName,TPrice,HPaid,DCreat,DExp,Creater,emName;
    GetInfo gi = new GetInfo();
    public StatisticalBills(String empName) {
        initComponents();
        emName=empName;
        gi.GetInfoTable( "spOrdersInfos",tblNewBill);
        gi.GetInfoTable("spOrdersInfoW",tblBillWaiting);
        gi.GetInfoTable( "spOrdersInfod",tblBillOver);
        gi.GetInfoTable( "spOrdersInfoc",tblBillCom);
        String a = Integer.toString(tblNewBill.getRowCount());
        lbTotalNew.setText(a);
        String b = Integer.toString(tblBillWaiting.getRowCount());
        lbTotalW.setText(b);
        String c = Integer.toString(tblBillOver.getRowCount());
        lbTotalO.setText(c);
        String d = Integer.toString(tblBillCom.getRowCount());
        lbTotalC.setText(d);
        jPanel.setOpaque(false);
        jPanel2.setOpaque(false);
        jPanel3.setOpaque(false);
        jPanel4.setOpaque(false);
        jPanel5.setOpaque(false);
        
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel = new javax.swing.JTabbedPane();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tblNewBill = new javax.swing.JTable();
        jLabel1 = new javax.swing.JLabel();
        lbTotalNew = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        tblBillWaiting = new javax.swing.JTable();
        jLabel2 = new javax.swing.JLabel();
        lbTotalW = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        tblBillOver = new javax.swing.JTable();
        jLabel3 = new javax.swing.JLabel();
        lbTotalO = new javax.swing.JLabel();
        jPanel5 = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        tblBillCom = new javax.swing.JTable();
        jLabel4 = new javax.swing.JLabel();
        lbTotalC = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();

        setPreferredSize(new java.awt.Dimension(840, 480));

        jPanel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jPanelMouseClicked(evt);
            }
        });

        tblNewBill.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Bill ID", "Customer Name", "Total Price", "Have Paid", "Date Create", "Expiry Date", "Status", "Creater"
            }
        ));
        tblNewBill.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                tblNewBillMouseReleased(evt);
            }
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblNewBillMouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(tblNewBill);

        jLabel1.setText("Total:");

        lbTotalNew.setText("jLabel2");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(18, 18, 18)
                        .addComponent(lbTotalNew)
                        .addGap(49, 49, 49))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 815, Short.MAX_VALUE)
                        .addContainerGap())))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(lbTotalNew))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE)
                .addGap(55, 55, 55))
        );

        jPanel.addTab("New Bill", jPanel2);

        tblBillWaiting.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Bill ID", "Customer Name", "Total Price", "Have Paid", "Date Create", "Expiry Date", "Status", "Creater"
            }
        ));
        tblBillWaiting.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblBillWaitingMouseClicked(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                tblBillWaitingMouseReleased(evt);
            }
        });
        jScrollPane3.setViewportView(tblBillWaiting);

        jLabel2.setText("Total:");

        lbTotalW.setText("jLabel3");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addGap(18, 18, 18)
                        .addComponent(lbTotalW)
                        .addGap(49, 49, 49))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 815, Short.MAX_VALUE)
                        .addContainerGap())))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lbTotalW)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 228, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(14, Short.MAX_VALUE))
        );

        jPanel.addTab("Bill Waiting", jPanel3);

        tblBillOver.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Bill ID", "Customer Name", "Total Price", "Have Paid", "Date Create", "Expiry Date", "Status", "Creater"
            }
        ));
        tblBillOver.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblBillOverMouseClicked(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                tblBillOverMouseReleased(evt);
            }
        });
        jScrollPane4.setViewportView(tblBillOver);

        jLabel3.setText("Total:");

        lbTotalO.setText("jLabel4");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                        .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 815, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(lbTotalO)
                        .addGap(29, 29, 29))))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(7, 7, 7)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(lbTotalO))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 223, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(28, Short.MAX_VALUE))
        );

        jPanel.addTab("Bill Overdue", jPanel4);

        tblBillCom.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Bill ID", "Customer Name", "Total Price", "Have Paid", "Date Create", "Expiry Date", "Status", "Creater"
            }
        ));
        tblBillCom.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblBillComMouseClicked(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                tblBillComMouseReleased(evt);
            }
        });
        jScrollPane5.setViewportView(tblBillCom);

        jLabel4.setText("Total:");

        lbTotalC.setText("jLabel5");

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 815, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(lbTotalC)
                        .addGap(24, 24, 24))))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(5, 5, 5)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(lbTotalC))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 223, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(30, Short.MAX_VALUE))
        );

        jPanel.addTab("Bill Complete", jPanel5);

        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/add.png"))); // NOI18N
        jButton2.setText("Add");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/detail.png"))); // NOI18N
        jButton1.setText("Detail");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(516, Short.MAX_VALUE)
                .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton1)
                .addGap(144, 144, 144))
            .addComponent(jPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 840, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 306, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton2)
                    .addComponent(jButton1))
                .addContainerGap(123, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void tblNewBillMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblNewBillMouseReleased

        int nRow = tblNewBill.getSelectedRow();
        BId = tblNewBill.getValueAt(nRow, 0).toString();
        CName = tblNewBill.getValueAt(nRow, 1).toString();
        TPrice = tblNewBill.getValueAt(nRow, 2).toString();
        HPaid = tblNewBill.getValueAt(nRow, 3).toString();
        DCreat = tblNewBill.getValueAt(nRow, 4).toString();
        DExp = tblNewBill.getValueAt(nRow, 5).toString();
        Creater = tblNewBill.getValueAt(nRow, 7).toString();
    }//GEN-LAST:event_tblNewBillMouseReleased

    private void jPanelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanelMouseClicked


        // TODO add your handling code here:
    }//GEN-LAST:event_jPanelMouseClicked

    private void tblBillWaitingMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblBillWaitingMouseReleased
        int nRow = tblBillWaiting.getSelectedRow();
        BId = tblBillWaiting.getValueAt(nRow, 0).toString();
        CName = tblBillWaiting.getValueAt(nRow, 1).toString();
        TPrice = tblBillWaiting.getValueAt(nRow, 2).toString();
        HPaid = tblBillWaiting.getValueAt(nRow, 3).toString();
        DCreat = tblBillWaiting.getValueAt(nRow, 4).toString();
        DExp = tblNewBill.getValueAt(nRow, 5).toString();
        Creater = tblBillWaiting.getValueAt(nRow, 7).toString();
    }//GEN-LAST:event_tblBillWaitingMouseReleased

    private void tblBillOverMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblBillOverMouseReleased
        int nRow = tblBillOver.getSelectedRow();
        BId = tblBillOver.getValueAt(nRow, 0).toString();
        CName = tblBillOver.getValueAt(nRow, 1).toString();
        TPrice = tblBillOver.getValueAt(nRow, 2).toString();
        HPaid = tblBillOver.getValueAt(nRow, 3).toString();
        DCreat = tblBillOver.getValueAt(nRow, 4).toString();
        DExp=tblNewBill.getValueAt(nRow, 5).toString();
        Creater = tblBillOver.getValueAt(nRow, 7).toString();
    }//GEN-LAST:event_tblBillOverMouseReleased

    private void tblBillComMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblBillComMouseReleased
      int nRow = tblBillCom.getSelectedRow();
        BId = tblBillCom.getValueAt(nRow, 0).toString();
        CName = tblBillCom.getValueAt(nRow, 1).toString();
        TPrice = tblBillCom.getValueAt(nRow, 2).toString();
        HPaid = tblBillCom.getValueAt(nRow, 3).toString();
        DCreat = tblBillCom.getValueAt(nRow, 4).toString();
        DExp=tblNewBill.getValueAt(nRow, 5).toString();
        Creater = tblBillCom.getValueAt(nRow, 7).toString();
    }//GEN-LAST:event_tblBillComMouseReleased

    private void tblBillComMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblBillComMouseClicked
                    if(BId!=null){
                new DetailedBills(BId,CName,TPrice,HPaid,DCreat,DExp,Creater).setVisible(true);
        }
    }//GEN-LAST:event_tblBillComMouseClicked

    private void tblBillOverMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblBillOverMouseClicked
             if(BId!=null){
                new DetailedBills(BId,CName,TPrice,HPaid,DCreat,DExp,Creater).setVisible(true);
        }
    }//GEN-LAST:event_tblBillOverMouseClicked

    private void tblBillWaitingMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblBillWaitingMouseClicked
      if(BId!=null){
                new DetailedBills(BId,CName,TPrice,HPaid,DCreat,DExp,Creater).setVisible(true);
        }
    }//GEN-LAST:event_tblBillWaitingMouseClicked

    private void tblNewBillMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblNewBillMouseClicked
      if(BId!=null){
                new DetailedBills(BId,CName,TPrice,HPaid,DCreat,DExp,Creater).setVisible(true);
        }
    }//GEN-LAST:event_tblNewBillMouseClicked

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        AddBill addbi = new AddBill(emName);
        MedicalStore.setDefaultLookAndFeelDecorated(true);
        MedicalStore.mains.removeAll();
        MedicalStore.mains.add("",addbi);
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
       if(BId!=null){
                new DetailedBills(BId,CName,TPrice,HPaid,DCreat,DExp,Creater).setVisible(true);
        }
    }//GEN-LAST:event_jButton1ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JTabbedPane jPanel;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JLabel lbTotalC;
    private javax.swing.JLabel lbTotalNew;
    private javax.swing.JLabel lbTotalO;
    private javax.swing.JLabel lbTotalW;
    private javax.swing.JTable tblBillCom;
    private javax.swing.JTable tblBillOver;
    private javax.swing.JTable tblBillWaiting;
    private javax.swing.JTable tblNewBill;
    // End of variables declaration//GEN-END:variables
}
